var path = require('path'),
    contextPath = path.join(__dirname, '../'),
    srcPath = path.resolve(contextPath,'src'),
    distPath = path .resolve(contextPath,'dist'),
    webpack = require('webpack'),
    node_modules = path.resolve(__dirname, 'node_modules'),
    HtmlWebpackPlugin = require('html-webpack-plugin');
    var toVue = path.resolve(node_modules, 'vue/dist/vue.min.js'),
        toLazy = path.resolve(node_modules, 'vue-lazyload/vue-lazyload.js'),
        toRouter = path.resolve(node_modules, 'vue-router/dist/vue-router.min.js'),
        toVuex=path.resolve(node_modules, 'vuex/dist/vuex.min.js');

module.exports = {
    entry:{
        app:'./src/index.js',
    },
    resolve:{
        extensions: ['.js', '.vue'],
        alias:{
            'zepto':path.resolve(srcPath,'static/js/zepto.js'),
            'imgSrc':path.resolve(srcPath,'store/imgSrc.js'),
            "Vue":toVue,
            "Vue-lazyload":toLazy,
            "Vue-router":toRouter,
            "Vuex":toVuex
        }
    },
    module:{
        noParse:[toVue,toLazy,toRouter,toVuex],
        rules:[
            {
                test:/\.js$/,
                exclude:/node_modules/,
                loader: 'babel-loader'
            },
            {
                test: /\.scss$/,
                exclude:/node_modules/,
                loader: 'style!css!sass',
            },
            
            {
                test: require.resolve('../src/static/js/zepto.js'),
                loader: 'exports-loader?window.Zepto!script-loader'
            }
        ]
    },
    plugins:[
        new HtmlWebpackPlugin({
            title:'Getting Started',
            template:path.resolve(srcPath,'./pages/index.html'),
            filename:path.resolve(distPath,'index.html'),
            minify: {
                removeComments: true,
                collapseWhitespace: true,
                removeAttributeQuotes: true
                // more options:
                // https://github.com/kangax/html-minifier#options-quick-reference
            },
            inject:true,
        })
        // ,
        // new webpack.ProvidePlugin({
        //   $: './static/js/zepto.js'
        // })
    ]
}